/* 
用来操作users集合数据的Model
*/

const mongoose = require('mongoose')
const moment = require('moment')

// 定义文档结构
const userSchema = mongoose.Schema({
  username: {
    type: String,
    require: true,
  },
  pwd: {
    type: String,
    require: true,
  },
  profile: {
    type: String,
    require: true,
  },
  creat_time: {
    type: String,
    default: () => moment().format('YYYY-MM-DD HH:mm:ss')
  },
}, {versionKey:false})

// 创建Model
const UserModel = mongoose.model('users', userSchema)

// 暴露Model
module.exports = UserModel